import Vue from "vue";
import Vuex from "vuex";
import Storage from "@/uitl/Storagehandle"; //sessionStorage的操作

Vue.use(Vuex);
//导入管理各个组件的store
//signalr
import Signalr from "./SignalR/signalr";
//学生
import Student from "./Student/Student";
import StudentLogin from "./Student/StudentLogin";
import Apply from "./Student/Apply";
import Group from "./Student/Group";
//教师
import Teacher from "./Teacher/Teacher";
import TeacherLogin from "./Teacher/TeacherLogin";
import TeacherGroup from "./Teacher/Group";

export default new Vuex.Store({
    state: {
        //因为vuex的数据在页面刷新时会重置（映射到Storagehandle）
        accessToken: Storage.getItem("accessToken") || "",
    },
    getters: {},
    mutations: {
        setAccessToken(state, data) {
            Storage.setItem(`accessToken`, data);
            state.token = data.token;
        },
        //退出
        Exit() {
            Storage.clear();
        },
    },
    actions: {},
    modules: {
        Signalr,
        Apply,
        Group,
        Student,
        StudentLogin,
        /////////////
        Teacher,
        TeacherLogin,
        TeacherGroup,
    },
});